<template>
  <a-modal :maskClosable="false"
    :title='title'
    :width='1024'
    :visible='visible'
    :confirmLoading='confirmLoading'
    @ok='handleOk'
    @cancel='handleCancel'
    cancelText='关闭'
    wrapClassName='ant-modal-cust-warp'
    style='top:5%;height: 85%;overflow-y: hidden'>
    <a-card :bordered='false' class='card-area'>
      <!-- 查询区域 -->
      <div class='table-page-search-wrapper'>
        <!-- 搜索区域 -->
        <a-form layout='inline' :label-col='labelCol' @keyup.enter.native='searchQuery'>
          <a-row :gutter='24'>
            <a-col :md='8' :sm='8'>
              <a-form-item label='服务类型'>
                <a-select v-model='queryParam.serviceType' placeholder='请选择服务类型'>
                  <a-select-option value=''>请选择</a-select-option>
                  <a-select-option value='0'>医生</a-select-option>
                  <a-select-option value='1'>护士</a-select-option>
                  <a-select-option value='2'>护工</a-select-option>
                  <a-select-option value='3'>社工</a-select-option>
                  <a-select-option value='4'>其他</a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :md='8' :sm='8'>
              <a-form-item label='服务名称'>
                <a-input placeholder='请输入服务名称' v-model='queryParam.projectName'></a-input>
              </a-form-item>
            </a-col>

            <span style='float: left;overflow: hidden;' class='table-page-search-submitButtons'>
           <a-col :md='6' :sm='24'>
               <a-button type='primary' @click='searchQuery' icon='search'>查询</a-button>
               <a-button type='primary' @click='searchReset' icon='reload' style='margin-left: 8px'>重置</a-button>
           </a-col>
        </span>
          </a-row>
        </a-form>
      </div>

      <a-row>
        <a-table
          ref='table'
          size='middle'
          bordered
          rowKey='id'
          :columns='columns'
          :dataSource='dataSource'
          :pagination='ipagination'
          :loading='loading'
          :customRow='doubleClick'
          :rowSelection='{type:selectedType, selectedRowKeys: selectedRowKeys, onChange: onSelectChange }'>
        </a-table>
      </a-row>
    </a-card>
  </a-modal>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction } from '@api/manage'
import { filterObj } from '@/utils/util'

export default {
  name: 'DepartList',
  mixins: [JeecgListMixin],
  data() {
    return {
      description: '测评服务项目',
      visible: false,
      title: '请选择服务项目',
      confirmLoading: false,
      /* table选择类型，单选radio或多选checkbox  */
      selectedType: 'checkbox',
      selectedRowKeys: [],
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 },
      },
      // 查询条件
      queryParam: {},
      // 表头
      columns: [
        {
          title: '服务类型',
          align: 'center',
          dataIndex: 'serviceType',
          customRender: function(t, r, index) {
            if (t == '0') {
              return '医生'
            } else if (t == '1') {
              return '护士'
            } else if (t == '2') {
              return '护工'
            } else if (t == '3') {
              return '社工'
            }
            return '其他'
          },
          width: 100
        },
        {
          title: '服务名称',
          align: 'center',
          dataIndex: 'projectName',
          width: 160
        },
        {
          title: '服务解决目标',
          align: 'center',
          dataIndex: 'projectTarget',
          width: 300
        }
      ],
      flag: false,
      url: {
        list: '/ch/evaluation/project/list',
      },
      loading: false,
    }

  },
  computed: {},
  created() {
  },
  methods: {
    doubleClick(record, index) {
      var that = this
      return {
        on: {
          // 这里是双击，单击改成click即可
          dblclick: () => {
            if (that.selectedType == 'radio') {
              that.selectedRowKeys = []
              that.$emit('signOk', record)
              that.close()
            }
          }
        }
      }
    },
    show() {
      this.visible = true
      this.loadData()
    },
    handleOk() {
      const that = this
      that.selectedRowKeys = []
      if (that.selectedType == 'radio') {
        that.$emit('signOk', this.selectionRows[0])
      } else {
        that.$emit('signOk', this.selectionRows)
      }
      that.close()
    },
    handleCancel() {
      this.close()
    },
    close() {
      this.visible = false
    },
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less'
</style>